package com.edu.service.impl;

import com.edu.bean.Book;
import com.edu.mapper.BookMapper;
import com.edu.service.BookService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:zyn
 * @Date:2025/11/21--12:47:51
 */
@Service
public class BookServiceImpl implements BookService {

    @Resource
    private BookMapper bookMapper;
    @Override
    public PageInfo<Book> getAllBook(int pageNum,int pageSize) {

        PageHelper.startPage(pageNum,pageSize);
        List<Book> bookList = bookMapper.selectAll();
        return   new PageInfo<>(bookList);
    }

    @Override
    public int removeBookById(int bookId) {
        return bookMapper.deleteBookById(bookId);
    }

    @Override
    public PageInfo<Book> gettiveBook(Book book,int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Book> bookList = bookMapper.selectiveBook(book);
        return new PageInfo<>(bookList);
    }
}
